package com.example.togethermove.ui.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.fragment.app.Fragment;

import com.example.togethermove.R;
import com.example.togethermove.base.BaseFragment;
import com.example.togethermove.bean.FragmentInfo;
import com.example.togethermove.ui.activity.masterSportsman.IssueDynamicActivity;
import com.example.togethermove.ui.activity.masterSportsman.SearchActivity;
import com.example.togethermove.ui.activity.masterSportsman.SignInActivity;
import com.example.togethermove.ui.activity.mine.DataPersonActivity;
import com.example.togethermove.ui.activity.togetherMove.SportSettingActivity;
import com.example.togethermove.utils.Utils;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

import static androidx.constraintlayout.motion.utils.Oscillator.TAG;
import static com.blankj.utilcode.util.CrashUtils.init;


/**
 * create an instance of this fragment.
 */
public class SportmaseterFragment extends BaseFragment {

    @BindView(R.id.tab_new_title_layout)
    TabLayout mTabNewTitleLayout;


    @BindView(R.id.tv_sportmaster_today)//今日目标
            TextView tv_sportmaster_today;
    @BindView(R.id.tv_sportmaster_everyday)//每天目标
            TextView tv_sportmaster_everyday;
    @BindView(R.id.tv_sportmaster_hostory)//历史最高
            TextView tv_sportmaster_hostory;



    @BindView(R.id.im_sportmaseter_sign_in)//签到
    ImageView im_sportmaseter_sign_in;
    @BindView(R.id.im_sportmaseter_search)//搜索
    ImageView im_sportmaseter_search;
    @BindView(R.id.im_sportmaseter_right)//
    ImageView im_sportmaseter_right;
    @BindView(R.id.flb_fly)//悬浮键
    FloatingActionButton flb_fly;


    Unbinder unbinder;

    //显示的集合
    private List<FragmentInfo> mShowItmes = new ArrayList<>();


    @Override
    protected View getSuccessView() {
        View view = View.inflate(getContext(), R.layout.fragment_sportmaseter, null);
        ButterKnife.bind(this, view);
        unbinder = ButterKnife.bind(this, view);
        init();
        Log.d(TAG, "getSuccessView: 1");
        return view;

    }

    @Override
    public Object requestData() {
        return null;
    }

    //初始化界面
    private void init() {

        String[] titles = Utils.getStringArray(R.array.general_viewpage_arrays);
        List<BaseFragment> newFragments = new ArrayList<>();
//        newFragments.add(new MineFragment())

        for (int i = 0; i < titles.length; i++) {
            mShowItmes.add(new FragmentInfo(newFragments.get(i),titles[i]));
        }

        //viewpager初始化
        //只要是fragment里面的fragment管理器就用getChildFragmentManager()
//        mVpNewsShowLayout.setAdapter(new NewsAdapter(getChildFragmentManager(),mShowItmes));
//
//        //tablayout与viewpager进行绑定
//        mTabNewTitleLayout.setupWithViewPager(mVpNewsShowLayout);

        //初始化tablayout 样式
        mTabNewTitleLayout.setTabTextColors(Color.parseColor("#9c9c9c"),Color.parseColor("#0B9A27"));

        //初始化指示器的颜色
        mTabNewTitleLayout.setSelectedTabIndicatorColor(Color.parseColor("#0B9A27"));

        //设置模式
        //填充模式
        mTabNewTitleLayout.setTabMode(TabLayout.MODE_FIXED);
        //滚动模式
//        mTabNewTitleLayout.setTabMode(TabLayout.MODE_SCROLLABLE);

    }



    @OnClick({R.id.im_sportmaseter_right,R.id.im_sportmaseter_sign_in,R.id.im_sportmaseter_search,
            R.id.flb_fly,

    })
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.im_sportmaseter_right:

                break;
            case R.id.im_sportmaseter_sign_in://签到
                toNewActivity(SignInActivity.class);
                break;
            case R.id.im_sportmaseter_search://搜索
                toNewActivity(SearchActivity.class);
                break;

            case R.id.flb_fly://发布动态
                toNewActivity(IssueDynamicActivity.class);
                break;





        }
    }










}